﻿using Abp;
using Abp.Domain.Entities.Auditing;
using Abp.Timing;
using Camc.Quality.Chat;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Camc.Quality.WorkFlow
{
    /// <summary>
    /// 消息推送表
    /// </summary>
    public class AffairMessage : FullAuditedEntity<Guid>
    {
        public const int MaxMessageLength = 4 * 1024; //4KB
        /// <summary>
        /// 发起用户Id
        /// </summary>
        public long UserId { get; set; }
        /// <summary>
        /// 目标用户Id
        /// </summary>
        [CanBeNull]
        public long? TargetUserId { get; set; }

        /// <summary>
        /// 当前接收角色
        /// </summary>
        public string RoleId{ get; set; }
        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 事务信息
        /// </summary>
        [Required]
        [StringLength(MaxMessageLength)]
        public string Message { get; set; }
        /// <summary>
        ///接收时间
        /// </summary>
        public DateTime? ReceiveTime { get; set; }
        /// <summary>
        /// 读取状态
        /// </summary>
        public ChatMessageReadState ReadState { get; private set; }
        /// <summary>
        /// 业务Id
        /// </summary>
        public Guid? SharedMessageId { get; set; }
        /// <summary>
        /// 消息类型Id
        /// </summary>
        public int AffairRemindId { get; set; }
        /// <summary>
        /// 是否是审批消息 true为审批
        /// </summary>
        public bool IsWorkFlow { get; set; } = false;

        /// <summary>
        /// 0 UsertoUser 1 UsertoRole 2 SystemtoUser
        /// </summary>
        [CanBeNull]   
        public int SendMode { get; set; }


        public void ChangeReadState(ChatMessageReadState newState)
        {
            ReadState = newState;
        }
    }
}
